<div style="float: right;padding: 10px;">
    <a href="<?php echo url_for('@homepage') ?>"><b>Volver a Opinics</b></a>
</div>
<div id="configuration_menu">
<ul>
    <li><a href="<?php echo url_for('@dashboard') ?>">Configuraci&oacute;n</a></li>
    <li class="selected"><a href="<?php echo url_for('@articles_new') ?>">Escribir un artículo</a></li>
    <li><a href="<?php echo url_for('@history') ?>">Historial</a></li>
</ul>
</div>
<form id="frm" action="<?php echo url_for('@articles_new') ?>" method="post" autocomplete="off">
    <input type="hidden" id="hdArticleId" name="hdArticleId" value="<?php echo $article->getId() ?>" />
    <input type="hidden" name="step" value="2" />
    <input type="hidden" id="hdIsResponseOf" name="hdIsResponseOf" value="<?php /* evalua si es respuesta de otro articulo, y coge su ID */ if(is_object($article_is_response)){ echo $article_is_response->getId(); } ?>" />
<div id="configuration_content">
  <div id="configuration_in">
    <div style="padding: 15px;">
      <?php if(is_object($article_is_response)){ ?>
        <div style="width: 100%;margin: 10px auto;">
          <div style="width: 80%;background-color: #FFF9D7; border: 1px solid #E2C822;margin: 0 auto;padding: 10px;">
              Este art&iacute;culo es una respuesta a
              <a href="<?php echo url_for('@article?id='.$article_is_response->getId().'&slug='.$article_is_response->getSlug()) ?>">
                <b><?php echo $article_is_response->getTitle() ?></b></a>
              de
              <a href="<?php echo url_for('@profile?id='.$article_is_response->getOwnerId()) ?>">
                <b>
                  <?php if(count($array_users)>0){ ?>
                    <?php foreach($array_users as $key => $practil_user){ ?>
                      <?php if($practil_user->{'id'} == $article_is_response->getAccount()->getPractilAccountId()){ ?>
                        <?php echo $array_users[$key]->{'name'}.' '.$array_users[$key]->{'lastName'}; ?>
                      <?php } ?>
                    <?php } ?>
                  <?php }else{ ?>
                    <?php echo 'Autor Nombre Completo' ?>
                  <?php } ?>
                </b>
              </a>
          </div>
        </div>
      <?php } ?>
        <br />
      <div class="section">
        <div class="title">
          <div>NUEVO ART&Iacute;CULO</div>
        </div>
        <div class="body">
          <table border="1" cellpadding="15">
            <tr class="table">
              <td colspan="3">
                <table width="100%">
                  <tr>
                    <td>T&iacute;tulo</td>
                    <td><input type="text" size="138" class="text" id="title" name="title" placeholder="Ingrese t&iacute;tulo al art&iacute;culo" /></td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr class="table">
              <td valign="top">
                <table width="100%">
                  <tr>
                    <td>Pa&iacute;s</td>
                    <td>
                      <select id="country" name="country" style="width: 162px;">
                        <?php foreach($countries as $country){ ?>
                          <?php if($country->getId()=='1'){ ?>
                            <option value="<?php echo $country->getId() ?>">
                                    Mundo_i18n_ed:</option>
                          <?php }else{ ?>
                            <option value="<?php echo $country->getId() ?>"
                                <?php if($sf_user->getAttribute('scountry')->getId()==$country->getId()){ echo 'selected'; } ?>>
                                    <?php echo $country->getName() ?> </option>
                          <?php } ?>
                        <?php } ?>
                      </select>
                    </td>
                  </tr>
                  <tr>
                    <td>Costo por visita</td>
                    <td>
                        <div id="divCostPub">
                          <select id="costPub" name="costPub" style="width: 162px;">
                            <?php foreach($costs as $cost){ ?>
                              <?php if($cost->getArticleTypeId()=='1'){/* publico */ ?>
                                <option value="<?php echo $cost->getId() ?>"
                                    <?php if(is_object($article_cost)){ ?>
                                    <?php if($article_cost->getCost()==$cost->getCost()){ echo 'selected'; } ?>
                                    <?php } ?>>
                                        <?php if($cost->getCost()!='0.00'){ ?>
                                        $ <?php echo $cost->getCost() ?> USD
                                        <?php }else{ ?>
                                        Free_i18ned
                                        <?php } ?>
                                </option>
                              <?php } ?>
                            <?php } ?>
                          </select>
                        </div>
                        <div id="divCostSpec" <?php if($article->getArticleTypeId()!='2'){ ?> style="display: none;" <?php } ?>>
                          <select id="costSpec" name="costSpec" style="width: 162px;">
                            <?php foreach($costs as $cost){ ?>
                              <?php if($cost->getArticleTypeId()=='2'){/* especializado */ ?>
                                <option value="<?php echo $cost->getId() ?>"
                                    <?php if(is_object($article_cost)){ ?>
                                    <?php if($article_cost->getCost()==$cost->getCost()){ echo 'selected'; } ?>
                                    <?php } ?>>
                                        $ <?php echo $cost->getCost() ?> USD
                                </option>
                              <?php } ?>
                            <?php } ?>
                          </select>
                        </div>
                    </td>
                  </tr>
                </table>
              </td>
              <td valign="top">
                <table width="100%">
                  <tr>
                    <td>Idioma</td>
                    <td>
                      <select id="language" name="language" style="width: 162px;">
                        <?php foreach($languages as $language){ ?>
                        <option value="<?php echo $language->getId() ?>"
                            <?php if(is_object($article->getLanguage())){ ?>
                            <?php if($language->getId()==$article->getLanguageId()){ echo 'selected'; } ?>
                            <?php } ?>>
                                <?php echo $language->getDescription() ?></option>
                        <?php } ?>
                      </select>
                    </td>
                  </tr>
                  <tr>
                    <td>Categor&iacute;a</td>
                    <td>
                        <div>
                          <select id="cboCategoria" name="category" style="width: 162px;" onchange="loadSubcategories1(this.value,function(){})">
                              <option value="">Select Category:</option>
                            <?php foreach($categories as $category){ ?>
                            <option value="<?php echo $category->getId() ?>"
                                <?php if(is_object($article->getCategory())){ ?>
                                <?php if($category->getId()==$article->getCategoryId()){ echo 'selected'; } ?>
                                <?php } ?>>
                                    <?php echo $category->getDescription() ?></option>
                            <?php } ?>
                          </select>
                            <input type="hidden" id="hdCboCategoria" name="hdCategory" />
                        </div>
                    </td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>
                        <div style="padding: 5px;">
                          <input type="checkbox" id="chkcategoria" onclick="sugerirCategoria()" />Sugiere una categoria
                        </div>
                        <div id="aux_categoria" style="display: none;">
                          <input type="text" id="aux_category" name="aux_category" placeholder="Categor&iacute;a" />
                        </div>
                    </td>
                  </tr>
                </table>
              </td>
              <td valign="top">
                <table width="100%">
                  <tr>
                    <td>Tipo</td>
                    <td>
                        <div style="float: left;">
                          <select id="type" name="type" onchange="setCosto(this.value)" style="width: 162px;">
                            <?php foreach($article_types as $at){ ?>
                            <option value="<?php echo $at->getId() ?>" <?php if($at->getId()==$article->getArticleTypeId()){ echo 'selected'; } ?>>
                                <?php echo $at->getDescription() ?></option>
                            <?php } ?>
                          </select>
                        </div>
                        <div style="float: left;padding: 5px;">
                          <a href="javascript:void(0)" onclick="alert('bla bla bla bla');" title="Qué es esto?">?</a>
                        </div>
                    </td>
                  </tr>
                  <tr>
                    <td>Subcategor&iacute;a</td>
                    <td>
                        <div>
                          <div id="divAjaxLoadSubcategoriesFrm">
                            <select id="cboSubcategoria" name="subcategory" style="width: 162px;" onchange="selectSubcategory(this.value)">
                                    <option value="">Select Subcategory:</option>
                            </select>
                          </div>
                            <input type="hidden" id="hdCboSubcategoria" name="hdSubcategory" />
                        </div>
                    </td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>
                        <div style="padding: 5px;">
                          <input type="checkbox" id="chksubcategoria" onclick="sugerirSubcategoria()" />Sugiere una subcategoria
                        </div>
                        <div id="aux_subcategoria" style="display: none;">
                          <input type="text" id="aux_subcategory" name="aux_subcategory" placeholder="Subcategor&iacute;a" />
                        </div>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>
      <div style="width: 940px;height: 1px;background-color: #cdd2d6;margin-left: 10px;"></div>
    <div style="padding: 15px;">
      <div class="section">
        <div class="title2">
          <div><b>RESUMEN</b></div>
        </div>
        <div class="body">
          <textarea style="width: 930px;height: 100%;min-height: 100%;" rows="20" id="txt_summary" name="summary"><?php echo $article->getSummary(); ?></textarea>
        </div>
      </div>
    </div>
      <br /><br />
      <div style="width: 940px;height: 1px;background-color: #cdd2d6;margin-left: 10px;"></div>
    <div style="padding: 15px;">
      <div class="section">
        <div class="title2">
          <div><b>CONTENIDO</b></div>
        </div>
        <div class="body">
          <textarea style="width: 930px;height: 300px;" rows="20" id="txt_content" name="content"></textarea>
        </div>
      </div>
    </div>
    <div style="padding: 15px;">
      <table width="100%" cellpadding="5">
        <tr>
          <td align="right">
              <input type="button" value="Guardar borrador" id="btnAutoSave" onclick="refreshAutoSave()" style="padding: 10px;" disabled />
                &nbsp;
              <input type="button" value="Descartar borrador" id="btnDiscard" onclick="discard('<?php echo $article->getId() ?>')" style="padding: 10px;" disabled />
                &nbsp;
              <input type="button" value="Continuar" onclick="return v_frm(this);" style="padding: 10px;" />
          </td>
        </tr>
      </table>
    </div>
  </div>
</div>
</form>
<script type="text/javascript">
var timer;
$(function(){
    timer = setTimeout("refreshAutoSave()",5000);/* inicializa el timer a los 5 segundos */
});
function refreshAutoSave(){
    clearTimeout(timer);
    autoSave();
    timer = setTimeout("refreshAutoSave()",10000); /* se auto-graba cada 10 segundos */
}
function discard(article_id){
    document.location.href="<?php echo url_for('@article_discard?id=') ?>"+article_id;
}
</script>